package _34define;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class Homework2 {
    public static void main(String[] args) {
        Map<String, User> map = new HashMap<>();
        map.put("zs", new User("zs", 18));
        map.put("ls", new User("ls", 19));
        map.put("wu", new User("wu", 20));
        map.put("zl", new User("zl", 21));
        map.put("aa", new User("aa", 18));
        Map<String, User> map1 = new HashMap<>();
        Set<Map.Entry<String, User>> set=map.entrySet();
        for (Map.Entry<String, User> stringUserEntry : set) {
            int a=stringUserEntry.getValue().age;
            if (a!=18){
                map1.put(stringUserEntry.getKey(),stringUserEntry.getValue());
            }
        }
        System.out.println(map1);
    }
}
class User{
    String name;
    int age;

    public User(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "User{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
